#-*- coding: utf-8 -*-
# autor: João Rebocho Nº6035
# data: 4/11/2013
# obs: Aula prática 7
#

#Tkinter

from Tkinter import*
class App:
	def __init__(self, master):
		frame = Frame(master); frame.pack()
		self.button = Button(frame,text ="Salir", fg = "red", command = 
			frame.quit)
		
		self.button.pack(side = LEFT)
		self.hi_there = Button(frame, text = "HOLA", command = self.say_hi)
		self.hi_there.pack(side = LEFT)
		pass 
	def say_hi(self):
		print "Hey, Caramba...!"
		pass 
root = Tk(); app = App(root)
root.mainloop(); root.destroy()

#wxpython
import wx
def treta(event): print "treta"
class Example(wx.Frame):
	def __init__(self, *args, **kwargs):
		super(Example, self).__init__(*args, **kwargs)
		self.InitUI()
		pass 
	def InitUI(self):
		menubar = wx.MenuBar(); fileMenu = wx.Menu()
		ftr = fileMenu.Append(103, 'Treta', 'Treta')
		fit = fileMenu.Append(wx.ID_EXIT, 'Qut', 'Qut')
		menubar.Append(fileMenu, '&File')
		self.SetMenuBar(menubar)
		self.Bind(wx.EVT_MENU, self.OnQuit, fit)	
		self.Bind(wx.EVT_MENU, treta, ftr)
		self.SetSize((300, 200)); self.SetTitle('Menu')
		self.Centre(); self.Show(True)
		pass 
	
	def OnQuit(self, e): 
		self.close()
		pass 
def main(): 
	ex = wx.App(); 
	Example(None); 
	ex.MainLoop()
	pass 
if __name__ == '__main__': 
	main()
		
#PyQt
import sys
from PyQt4 import QtGui
class Example(QtGui.QMainWindow):
	def __init__(self):
		super(Example, self).__init__(); 
		self.initUi()
		pass 
	
	def initUi(self):
		eact = QtGui.QAction(QtGui.QIcon('exit.png'), '&Exit', self)
		tact = QtGui.QAction(QtGui.QIcon('exit.png'), '&Treta', self)
		eact.setShortcut('Ctrl+Q')
		eact.setStatusTip('Exit application')
		eact.triggered.connect(QtGui.qApp.quit)
		tact.triggered.connect(treta)
		self.statusBar()
		mb = self.menuBar(); fm = mb.addMenu('&File')
		fm.addAction(tact); fm.addAction(eact)
		self.setGeometry(300, 300, 300, 200)
		self.setWindowTitle('Menubar'); self.show()
		pass 

def treta():
	print "Treta"
	pass 
	
def main():
	app = QtGui.QApplication(sys.argv)
	ex = Example()
	sys.exit(app.exec_())
	pass 
		
if __name__ == '__main__': 
	main()
